package com.atguigu.service;

import com.atguigu.bean.Department;
import com.atguigu.mapper.DepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;

    @Cacheable(value = {"dept"})
    public Department getDeptById(Integer id) {
        return departmentMapper.getDeptById(id);
    }

    public List<Department> getDepts() {
        return departmentMapper.getDepts();
    }

    public int addDept(Department dept) {
        return departmentMapper.insertDept(dept);
    }

    public int editDept(Department dept) {
        return departmentMapper.updateDept(dept);
    }

    public int deleteDept(Integer id) {
        return departmentMapper.deleteDept(id);
    }
}
